<html>

<head>
    <script>
        var a = {
            getString(payload, resolve) {
                resolve(`myStr-${payload}`);
            },
            async delay(payload) {
                let p = new Promise(resolve => {
                    setTimeout(this.getString, 3000, payload, resolve);
                });
                let str = await p;
                return str;
            },
            *test(payload, { call, put }) {
                const rp = yield call(this.delay.bind(this), payload);
                yield put({
                    name: rp
                });
            },
            call(fn, argu) {
                return fn(argu);
            },
            put({ name }) {
                return { name };
            },
            async start() {
                let g = this.test('张', { call: this.call, put: this.put });
                let promise = g.next().value;
                let rp = await promise;
                let data = g.next(rp).value;
                alert(data.name);
            }
        }
        a.start();
    </script>
</head>

<body>
    <div></div>
</body>

</html>